var keyword = getUrlParam('keyword');
    var datas;
    $.ajax({
        type: "get",
        url: Url + "search/" + keyword,
        async: false,
        timeout : 20000,
        beforeSend: function (xhr) {
            showDiv()
        },
        success: function (data) {
            hiddenDiv()
            console.log(data);
            if (data.length != 0) {
                datas = data;
                setdatas(data)
            } else {
                $(".discount-main-no").css("display", "block")
            }
        },
        error: function (request, status, err) {
            failure(status)
        }
    })
//点击销量事件
//点击价格事件
    function setdatas(data) {
        var str = '';
        for (var i = 0; i < data.length; i++) {
            str += '<div class="cla-goods">' +
                '<a href="goods_detail.html?id=' + data[i].products_id + '">' +
                '<image class="avatar" src="' + data[i].recommend + '"  />' +
                '<div class="writtenWords">' +
                '<div class="title">' + data[i].products_name + '</div>' +
                '<div class="price">￥' + data[i].products_sellingprice + '</div>' +
                '</div>' +
                '</a>' +
                '</div>'
        }
        $(".classification-main").html(str)
    }

    $(".classification_btn").click(function () {
        if ($(this).attr("_id") == 0) {
            $(this).children("span").addClass("thison");
            $(this).siblings().children("span").removeClass("thison");
            $(this).siblings().children("img").attr("src", "/static/index/img/icon-sort-bottom.png");
            setdatas(datas);
            console.log(datas)
        } else if ($(this).attr("_id") == 1) {
            var newDatas = datas;
            $(this).children("span").addClass("thison");
            $(this).children("img").attr("src", "/static/index/img/icon-sort-bottom-selected.png");
            $(this).siblings().children("span").removeClass("thison");
            newDatas.sort(function (a, b) {
                return b.products_sellingprice - a.products_sellingprice;
            });
            setdatas(newDatas);
            console.log(datas)
        }
    });
    $("#main").on("click", ".classification_btn_img", function () {
        if ($(this).attr("_id") == 0) {
            var newDatas = datas;
            $(this).attr({"src": "/static/index/img/icon-sort-top-selected.png", "_id": "1"});
            newDatas.sort(function (a, b) {
                return a.products_sellingprice - b.products_sellingprice;
            });
            setdatas(newDatas);
            console.log(datas)
        } else {
            var newDatas = datas;
            $(this).attr({"src": "/static/index/img/icon-sort-bottom-selected.png", "_id": "0"});
            newDatas.sort(function (a, b) {
                return b.products_sellingprice - a.products_sellingprice;
            });
            setdatas(newDatas);
            console.log(datas)
        }
    });


    $(".priceSort").on('click', function () {

    });

    $(".SalesSort").on('click', function () {

    });
